Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARC-814 RepoSyncState table as source of truth #928

Merged
merged 10 commits into from
Dec 16, 2021

Conversation

mboudreau
Copy link
Contributor

Adding new FF and making all 'reads' for repo sync state come from the new table. We're still writing to the JSON blob column so we can switch back in case of issues. Next step after fully deployed is to remove the repoSyncState column and all references to it.

@mboudreau mboudreau marked this pull request as ready for review November 24, 2021 07:44
Copy link
Contributor

@thombergs thombergs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The jiraHost is missing on one feature flag evaluation, otherwise, looks good!

src/api/index.ts Show resolved Hide resolved
thombergs
thombergs previously approved these changes Dec 7, 2021
thombergs
thombergs previously approved these changes Dec 10, 2021
package-lock.json Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
@@ -104,7 +112,7 @@ export default async (
)
);

const failedConnections = getFailedConnections(
const failedConnections = await getFailedConnections(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean failedConnections has always been an unresolved promise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it used to be a sync function which I changed to async for the booleanFlag call

if (repo) {
this.repoUpdatedAt = new Date(repo.repository?.updated_at || Date.now());
this.repoUpdatedAt = new Date(repo.repository?.updated_at ?? Date.now());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use ?? instead of || here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? is null coalescing since we're looking for if it's undefined or null. A test that we use is using new Date(0) because we wanted to compare the specific 8601 date and instead of using a random number, 0 seemed easy, but 0 is falsy, hence it would return Date.now() and fail the test.

thombergs
thombergs previously approved these changes Dec 15, 2021
@KAbakumovAtl
Copy link
Contributor

Please link the filled up FD ticket

@mboudreau
Copy link
Contributor Author


function mapSyncStatus(syncStatus: string): string {
function mapSyncStatus(syncStatus: SyncStatus = SyncStatus.PENDING): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case this method will have to use the default parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subscription.syncStatus is optional, we needed a way to handle in the off chance that it wasn't set yet, but almost certainly would be by this point as this is for current subscriptions which any new subscriptions is automatically synced and set to PENDING. https://github.com/atlassian/github-for-jira/blob/main/src/models/subscription.ts#L166

@@ -94,7 +95,7 @@ export default class Installation extends Sequelize.Model {
await this.destroy();
}

async subscriptions(): Promise<Subscription[]> {
async subscriptions(): Promise<SubscriptionClass[]> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what's the difference between Subscription and SubscriptionClass? And how does this type change affect things?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we need to fix that at some point. It's because we're using an export default class called Subscription at src/models/subscription but we also have a export const value called Subscription which is an instance of the class that's being built by Sequelize and provided by src/models/index. Values and Class types are different and you cannot place a value as a type of a function. If you look at the imports at the top of the file, I had to import both the class type and the value as you need to refer to the value if you want to do operations on the DB with sequelize or else it'll just error at runtime.

@KAbakumovAtl
Copy link
Contributor

@KAbakumovAtl https://hello.atlassian.net/browse/FD-27945
Thanks,

Just a few things:

  • The following fields are missing:

    • Roll-out Plan
    • Due date
      (Please refer to go/arc-flags for the fields guide)
  • For "Support Readiness" we should say that the change potentially affects Backfill process

  • Optionally for monitoring we can also add a Splunk query to errors in the Backfill queue

@mboudreau
Copy link
Contributor Author

@KAbakumovAtl done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants